<template>
	<view >
		<custom-navigation-bar title="资金明细"></custom-navigation-bar> 
		 
		<view style="width: 100%;float: left;height: 150rpx;"></view>
		 <view class="list-item"  >
		     <view style="width: 60%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;">
				 类型
			 </view>
			 <view style="width: 20%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;">
			 	金额
			 </view>
			  <view style="width: 20%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;">
			 	余额
			 </view>
		 </view>
		<view v-if="data.length>0">
			<view class="list-item" v-for="(item,index) in data" :key="index" > 
			    <view style="width: 60%;height: 50rpx;line-height: 50rpx;float: left;text-align:center;color: #CCCCCC;">
			    	{{item.createTime}}
			    </view>  
				<view style="width: 60%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;"> 
					<view v-if="item.type==1">提现</view>
					<view v-if="item.type==2">拉新分佣</view>
					<view v-if="item.type==3">销售分佣</view>
					<view v-if="item.type==4">合伙人分佣</view>
					<view v-if="item.type==5">平台分佣</view>
					<view v-if="item.type==6">产品销售</view>
					<view v-if="item.type==7">下级管家销售分佣</view>
				</view>
				<view style="width: 20%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;">
					{{item.money}}
				</view>
				 <view style="width: 20%;float: left;height: 60rpx;line-height: 60rpx;text-align: center;">
					{{item.balance}}
				</view>
				
			</view>
			<view class="more" v-if="pageData.more" @click="getMore()">
			     加载更多
			</view>
			<view class="more" v-if="!pageData.more">
			     无更多数据
			</view>
		</view>
		<view class="more" v-if="data.length==0">
		     暂无数据
		</view> 
		<view style="width: 100%;height: 60rpx;float: left;"></view> 
	</view>
</template>

<script setup>
	import CustomNavigationBar from '@/components/CustomNavigationBar.vue'; 
	 
	import http from '../../../utils/http';
	  
	const searchInitData=ref({});
	const searchDate=ref({}); 
	//----查询开始----
	const data=ref([]); 
	const pageData=ref(
		{
			pageIndex:1,
			pageSize:10,
			more:true
		}
	);
	function getMore(){
		pageData.value.pageIndex=pageData.value.pageIndex+1;
		initData();
	}
	initData();
	function initData(){
		uni.showLoading({
			title: '数据加载中',
			mask:true
		}); 
		http.request({
		 	url: "/balance/detail/list",
		 	method: "POST",
		 	data: { 
				userId:getApp().globalData.shopUserId,
				pageIndex:pageData.value.pageIndex,
				pageSize:pageData.value.pageSize,
				balanceDetail:{
					
				}
		 	}
		}).then((responseData) => { 
			uni.hideLoading();
			if(responseData.code==1){
				if(pageData.value.pageIndex==1){
					data.value=responseData.data;
				}else{
					if(responseData.data.length==0){
						pageData.value.more=false;
					}else{
						for(var i=0;i<responseData.data.length;i++){
							data.value.push(responseData.data[i])
						} 
					}
				}
			}else if(responseData.code==0){
				uni.showToast({
					icon: 'error',
					title: responseData.message
				})
			}else if(responseData.code==-1){
				uni.navigateTo({
					url: "/pages/login/login"
				});
			}
		}).catch((err) => {
			uni.hideLoading();
		 	uni.showToast({
		 		icon: 'error',
		 		title: '请求失败'
		 	})
		})
	} 
</script>

<style>
	@import "../../list/list.scss";
	@import "../../login/xieyi.scss";
	 .xiaoqu_item{
		 width: 90%;float: left;margin-left: 5%;background: white;margin-top: 20rpx;height: 80rpx;line-height: 80rpx;border-radius: 20rpx;
	 }
	 .more{
		 width: 100%;text-align: center;line-height: 50rpx;color: #666666;font-size: 25rpx;float: left;margin-top: 10rpx;
	 }
	 .edit{
		 float: right;color: dodgerblue;margin-right: 50rpx;
	 }
</style>